#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
日志工具模块
"""

import os
import sys
import logging
from config.settings import settings

def setup_logging():
    """设置日志系统"""
    # 确保日志目录存在
    log_dir = os.path.dirname(settings.LOG_FILE)
    if log_dir and not os.path.exists(log_dir):
        os.makedirs(log_dir)
    
    # 配置日志
    logging.basicConfig(
        level=getattr(logging, settings.LOG_LEVEL),
        format=settings.LOG_FORMAT,
        handlers=[
            logging.StreamHandler(sys.stdout),
            logging.FileHandler(settings.LOG_FILE, encoding='utf-8')
        ]
    )
    
    print("✅ 日志系统初始化完成")

def get_logger(name: str) -> logging.Logger:
    """获取logger实例"""
    return logging.getLogger(name) 